import requests
from lxml import etree
import logging


def get_cip_data():
    headers = {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36',
    }
    url = 'http://www.cip.cc/'

    try:
        page_text = requests.get(url, headers=headers).text
        tree = etree.HTML(page_text)
        text = tree.xpath('/html/body/div/div/div[3]/pre/text()')[0]
        return text.split('\n')[0]
    except Exception as e:
        logging.error(f"Failed to get data from {url}: {e}")
        return None


if __name__ == "__main__":
    result = get_cip_data()
    if result:
        print(result)
